<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css"  media="all">
</head>
<body>
	<form class="layui-form">
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>
				添加角色</label>
			<div class="layui-input-inline">
				<input type="text" name="name" id="name" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>	
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即添加</button>
			</div>
		</div>
	</form>
</body>
 <script type="text/javascript" src="js/User.js" ></script>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script>
		layui.use(['form','upload'], function() {
			var form = layui.form;
			var upload=layui.upload;
			var $ = layui.jquery; 
			form.on('submit(formDemo)', function(data) {
				var d = data.field;
				d.method = "addRoles";
				console.log(d);
				var url = globalData.server+'roles/addRoles';
				$.post(url, d, function(data) {
					if (data.count > 0) {
						console.log('添加成功');
						var index = parent.layer.getFrameIndex(window.name); 
						parent.layer.close(index); 
					}
				}, "json");
				return false;
			});
		});
	</script>
</html>